<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <title>马思特奥赛培训学校网络管理系统</title>

    <script type="text/javascript" th:src="@{/webjars/jquery/1.9.1/jquery.js}"></script>
    <script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.7/js/bootstrap.js}"></script>

    <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/demo.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/ready.css}">
</head>
<body>
<div class="wrapper">

    <div th:replace="teacher/public-teacher-index :: header"></div>
    <div th:replace="teacher/public-teacher-index :: left"></div>

    <div class="main-panel">
        <div class="content">
            <div class="row">
                <!--<div class="col-md-1"></div>-->
                <div class="col-md-11">
                    <div class="card" style="width:100%;height:100%;">
                        <div class="card-header">
                            <h5 class="card-title"></h5>
                        </div>
                        <div class="card-body">
                            <form class="form-horizontal" enctype="multipart/form-data">
                                <input type="hidden" th:value="${workapproval.id}" id="id_work">
                                <div class="form-group card-header">
                                    <label class="col-sm-2 control-label">出差类型</label>
                                    <div class="col-sm-2">

                                        <span class="form-control" th:text="${workapproval.typeName}"></span>
                                    </div>
                                </div>
                                <div class="form-group card-header">
                                    <label class="col-sm-2 control-label">时间</label>
                                    <div class="col-sm-4">
                                        <span class="form-control" th:text="${time}"></span>
                                    </div>
                                </div>
                                <div class="form-group card-header">
                                    <label class="col-sm-2 control-label">新闻稿</label>
                                    <div class="col-sm-6">
                                        <textarea class="form-control" rows="4" cols="100" id="news"></textarea>
                                    </div>
                                </div>
                                <div class="form-group card-header">
                                    <label class="col-sm-2 control-label">报告类型</label>
                                    <div class="col-sm-2">
                                        <select class="form-control" id="flag">
                                            <option th:value="0">公开</option>
                                            <option th:value="1">私有</option>
                                        </select>
                                    </div>
                                </div>
                            </form>
                            <form class="form-horizontal" id="info">
                                <div class="form-group card-header">
                                    <label class="col-sm-2 control-label">附件</label>
                                    <div class="col-sm-4">
                                        <input type="file" class="form-control" name="file">
                                        <span>请以rar文件提交（内容包括视屏，word，文件）</span>
                                    </div>
                                </div>
                                <div class="form-group text-center">
                                    <button type="button" class="btn btn-primary" id="sub">提交</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
</body>
<script type="text/javascript">
    //1、使用 window.locaion.href 获得项目的根路径
    var curWwwPath = window.location.href;
    //2、获得主机地址之后 的目录
    var pathname = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathname);
    //3、获得主机地址
    var localhostPath = curWwwPath.substring(0, pos);

    $("#sub").click(function () {
        var formdata = new FormData(document.getElementById("info"));

        var a1 = $("#id_work").val()
        var a2 = $("#news").val()
        var a3 = $('#flag option:selected').val();

        formdata.append("id_work", a1)
        formdata.append("news", a2)
        formdata.append("flag", a3)

        $.ajax({
            url:localhostPath + "/edumanagement/teacher/fill_in_w",
            type: "post",
            data: formdata,
            async: false,
            cache: false,
            contentType: false, //不设置内容类型
            processData: false, //不处理数据
            success: function (result) {
                alert("提交成功")
                window.location.href = "workapprovaldata"
            }
        })
    })
</script>
</html>